/**
 * 
 * @param {Object} [oldValue]
 * @param {Object} [newValue]
 * @param {JSEvent} [event]
 * 
 * @properties={typeid:24,uuid:"BE1DFF20-5086-4740-ACF2-1041E0DDD815"}
 */
function onDataChange_recalcular(oldValue, newValue, event) {
	if (importe_carga_debe < 0)
	{
		importe_carga_debe = importe_carga_debe * -1
	}	    
	if (importe_carga_haber < 0)
	{
		importe_carga_haber = importe_carga_haber * -1
	}	
	globals.gtotal_debe = 0
	globals.gtotal_haber = 0
	for (var i = 1 ; i <= controller.getMaxRecordIndex() ; i++)
	{
		controller.setSelectedIndex(i)
		if (importe_carga_debe != null)
		{
			globals.gtotal_debe  += importe_carga_debe.toFixed(2)*1
		} 
		if (importe_carga_haber != null)
		{
			globals.gtotal_haber += importe_carga_haber.toFixed(2)*1			
		}
	}
	return true 
}

/**
 * Perform the element default action.
 *
 * @param {JSEvent} event the event that triggered the action
 *
 * @properties={typeid:24,uuid:"FEAB239C-8530-4097-B070-4E63DE07E5D8"}
 */
function onAction_leyenda(event) {
	globals.gform_origen = "limbo_modif_det"
	globals.formEnVentana('limbo_carga_leyendas','LEYENDAS','Leyendas')
}

/**
 * Perform the element default action.
 *
 * @param {JSEvent} event the event that triggered the action
 *
 * @properties={typeid:24,uuid:"43D6BA9E-EBF3-483C-871A-6879DB59FAC6"}
 */
function onAction_borrar(event) {
	//controller.deleteRecord() se cambió - ahora anula importe - porque savedata no restaura los dados de baja
	importe_carga_debe = 0
	importe_carga_haber = null
	onDataChange_recalcular()
	
}

/**
 * Handle focus element loosing focus.
 *
 * @param {JSEvent} event the event that triggered the action
 *
 * @returns {Boolean}
 *
 * @properties={typeid:24,uuid:"2F7BAFE0-2ED1-4191-A5F9-8B085469788E"}
 */
function onFocusLost_cuenta(event) {
	elements.cuentas_id.caretPosition = 0
	return true
}
